package com.ruoyi.logistic.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.logistic.domain.NetworkUndertakeCentreAssessmentCollect;
import com.ruoyi.logistic.domain.NetworkUndertakeCentreAssessmentDetail;
import com.ruoyi.logistic.domain.PageDate;
import com.ruoyi.logistic.domain.vo.NetworkUndertakeCentreAssessmentCollectVo;
import com.ruoyi.logistic.domain.vo.NetworkUndertakeCentreAssessmentDetailVo;
import com.ruoyi.logistic.mapper.NetworkUndertakeCentreAssessmentCollectMapper;
import com.ruoyi.logistic.mapper.NetworkUndertakeCentreAssessmentDetailMapper;
import com.ruoyi.logistic.service.NetworkUndertakeCentreAssessmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NetworkUndertakeCentreAssessmentServiceImpl implements NetworkUndertakeCentreAssessmentService {
    @Autowired
    private NetworkUndertakeCentreAssessmentDetailMapper networkUndertakeCentreAssessmentDetailMapper;
    @Autowired
    private NetworkUndertakeCentreAssessmentCollectMapper networkUndertakeCentreAssessmentCollectMapper;
    @Override
    public List<NetworkUndertakeCentreAssessmentDetail> selectAll(PageDate pageDate) {
        PageHelper.startPage(pageDate);
        return networkUndertakeCentreAssessmentDetailMapper.selectAll();
    }

    @Override
    public Boolean insert(NetworkUndertakeCentreAssessmentDetail networkUndertakeCentreAssessmentDetail) {
        return networkUndertakeCentreAssessmentDetailMapper.insert(networkUndertakeCentreAssessmentDetail);
    }

    @Override
    public Boolean update(NetworkUndertakeCentreAssessmentDetail networkUndertakeCentreAssessmentDetail) {
        return networkUndertakeCentreAssessmentDetailMapper.update(networkUndertakeCentreAssessmentDetail);
    }

    @Override
    public Boolean deleteById(Integer id) {
        return networkUndertakeCentreAssessmentDetailMapper.deleteById(id);
    }

    @Override
    public List<NetworkUndertakeCentreAssessmentDetail> search(NetworkUndertakeCentreAssessmentDetailVo networkUndertakeCentreAssessmentDetailVo) {
        PageHelper.startPage(networkUndertakeCentreAssessmentDetailVo.getPageDate());
        return networkUndertakeCentreAssessmentDetailMapper.search(networkUndertakeCentreAssessmentDetailVo);
    }

    @Override
    public List<NetworkUndertakeCentreAssessmentCollect> assessmentCollect(NetworkUndertakeCentreAssessmentCollectVo networkUndertakeCentreAssessmentCollectVo) {
        PageHelper.startPage(networkUndertakeCentreAssessmentCollectVo.getPageDate());

        List<NetworkUndertakeCentreAssessmentCollect> assessmentCollects = networkUndertakeCentreAssessmentCollectMapper.assessmentCollect(networkUndertakeCentreAssessmentCollectVo);
        assert assessmentCollects != null;
        for (NetworkUndertakeCentreAssessmentCollect assessmentCollect : assessmentCollects){
                assessmentCollect.setAuditDate(networkUndertakeCentreAssessmentCollectVo.getMonth());
        }
        return assessmentCollects;
    }
}
